<?php
	namespace Controller;
	class Controller {
		private $data;
		private $page;
		private $format;

		public function __construct($data){
			$this->data = $data;
			$this->page = (isset($this->data['page'])?$this->data['page']:'index');
			$this->page[0] = strtoupper($this->page[0]);
			$this->page = 'Pages\\'.$this->page;
			$this->format = (isset($this->data['format'])?$this->data['format']:'html');
		}
		public function exec(){
			try{
				$p = new $this->page();
			}
			catch(Exception $e){
				echo '<pre>';
				echo 'Erreur';
				print_r($e);
				echo '</pre>';
			}
			$v = new \Vue\Vue($p);
			$ret = $p->exec($this->data);
			if($ret == ''){
				$v->display($this->format);
			}
			else{
				$v->move($ret);
			}
		}
	}
?>
